<%@page import="java.util.Iterator"%>
<%@page import="java.util.TreeSet"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.TreeMap"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=path%>/css/achTable.css" rel="stylesheet" type="text/css" />

<script>
	function toggle(oDiv) {
		var aDiv = document.getElementById(oDiv);
		aDiv.style.display = (aDiv.style.display == "none") ? "block" : "none";
	}

	function show(oBj) {
		window.alert(oBj.tagName);
	}
</script>
<title>俱乐部业绩汇总</title>
</head>

<body>
	<%
		TreeMap<String, String> yearMap = (TreeMap<String, String>) request
				.getAttribute("yearMap");
		TreeMap<String, TreeMap<String, String>> monthsOfYearList = (TreeMap<String, TreeMap<String, String>>) request
				.getAttribute("monthsOfYearList");

		TreeMap<String, TreeMap<String, String>> typeOfYearMonthList = (TreeMap<String, TreeMap<String, String>>) request
				.getAttribute("typeOfYearMonthList");
		TreeSet<String> yearSet = new TreeSet<String>(yearMap.keySet());
	%>

	<center>
		<br />
		<div id="achTitle">
			<h2>业绩汇总</h2>
		</div>
		<br />
		<div id="achTableDiv">
			<table id="achTable" cellpadding="0" cellspacing="0">

				<!---------------表头----------->
				<tr class="tableTitle">
					<td class="openTable">操作</td>
					<td class="type">年份</td>
					<td class="achievement">销售额</td>
					<td class="remark">&nbsp;</td>
				</tr>
				<%
					Iterator<String> yearIt = yearSet.iterator();

					while (yearIt.hasNext()) {
						String year = yearIt.next();
						int y = 0;
						String outRowId = year + y;
						y++;
				%>

				<!---------------有内容的行----------->
				<tr class="contentRow">
					<td class="contentOpenCol"
						onclick="toggle('innerTableDiv<%=outRowId%>')">展开</td>
					<td class="contentCol"><%=year%></td>
					<td class="contentCol"><%=yearMap.get(year)%></td>
					<td class="contentCol">&nbsp;</td>
				</tr>
				<!------------内嵌的表格------------------------------------------------------------------------------------->
				<tr>
					<td colspan="4">
						<div id="innerTableDiv<%=outRowId%>" class="innerDiv">
							<table class="innerTable" cellpadding="0" cellspacing="0">
								<tr class="tableTitle">
									<td class="openTable">操作</td>
									<td class="typeOfMonth">月份</td>
									<td class="achievement">销售额</td>
									<td class="remark"></td>
								</tr>

								<%
									TreeMap<String, String> monthMap = monthsOfYearList.get(year);
										TreeSet<String> monSet = new TreeSet<String>(monthMap.keySet());
										Iterator<String> monthIt = monSet.iterator();
										while (monthIt.hasNext()) {
											String month = monthIt.next();
											int x = 0;
											String rowId = month + x;
											x++;
								%>

								<tr class="contentRow">
									<td class="contentOpenCol"
										onclick="toggle('innerInnerTableDiv<%=outRowId+rowId%>')">展开</td>
									<td class="contentCol"><%=month%></td>
									<td class="contentCol"><%=monthMap.get(month)%></td>
									<td class="contentCol">&nbsp;</td>
								</tr>
								<tr>
									<td colspan="4">
										<div id='innerInnerTableDiv<%=outRowId+rowId%>' class="innerInnerDiv">
											<table width="300" class="innerInnerTable" cellpadding="0"
												cellspacing="0">
												<tr class="contentRow">
													<td class="sellType" colspan="2">销售类型</td>
													<td class="sellMount" colspan="2">销售额</td>

												</tr>

												<%
													TreeMap<String, String> typeMap = typeOfYearMonthList
																	.get(year + month);
															TreeSet<String> typeName = new TreeSet<String>(
																	typeMap.keySet());
															Iterator<String> typeIterator = typeName.iterator();
															while (typeIterator.hasNext()) {
																String typeString = typeIterator.next();
												%>




												<tr class="contentRow">
													<td class="contentCol" colspan="2"><%=typeString%></td>
													<td class="contentCol" colspan="2"><%=typeMap.get(typeString)%></td>
												</tr>
												<%
													}
												%>

											</table>

										</div>
									</td>
								</tr>
								<%
									}
								%>

							</table>
						</div>
					</td>
				</tr>


				<%
					}
				%>
			</table>

		</div>
	</center>
</body>
</html>

